package com.markerhub.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author jsx on 2023/2/4
 **/
public class DateUtils {

    //转日期转为yyyy-MM-dd格式
    public static  String dateToFormat(Date date){
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String nowdayTime = dateFormat.format(date);
        return nowdayTime;
    }

    //转日期为yyyy-MM-dd HH:ss:mm格式
    public static String getTime(Date date){
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String nowdayTime = dateFormat.format(date);
        return nowdayTime;
    }

    public static void main(String[] args) {
        System.out.println(dateToFormat(new Date()));
    }
}
